<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier-html-xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<title>${aier_title}</title>
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}ui.css" />
<link rel="Stylesheet" href="${aier_css_url}jq/jq.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css" />
<link rel="stylesheet"
	href="${aier_css_url}social/module/reset.css" />
<link rel="stylesheet"
	href="${aier_css_url}social/user/accountSettings/common.css" />
<link rel="stylesheet"
	href="${aier_css_url}social/user/accountSettings/pi.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/hh/ui.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>

<script type="text/javascript" src="${aier_js_url}97/WdatePicker.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
</head>
<!-- 个人基本资料页面 -->
<body>
	<!-- 顶栏 -->
	<s:action name="userhomecomm_homeHead" namespace="/user"
		executeResult="true"></s:action>

	<!-- 正文 -->
	<div id="hfContent" class="ar-content">
		<div class="content-main">
			<div class="main-content wrap-bg clearfix">
				<!-- 左侧栏 -->
				<s:action name="useraccountsettings_aSettingsLeft" namespace="/user"
					executeResult="true"></s:action>
				<!-- 右侧内容 -->
				<div class="ae-right">
					<div class="right-main">
						<div class="right-main-top">
							<div class="binfo-title">
								<h3>我的家人</h3>
							</div>
							<div class="right-line"></div>
						</div>
						<p class="bind-num-tip">
							最多可关联 <em>5</em> 个家人
						</p>
						<div class="right-main-c clearfix" id="babyshow">
							
						</div>
					</div>
				</div>

			</div>

		</div>
		<!-- footer copyright -->
		<s:action name="userhomecomm_homeFooter" namespace="/user" executeResult="true"></s:action>
		<!-- /footer copyright -->
	</div>
</body>
<script type="text/javascript">
	$(document).ready(function() {
		load_baby();
	});
	
	//加载宝宝
	function load_baby(){
		var fun = function(data){
			if (data.s == 1) {
				if(data.babyList.length > 0){
					var msg_html = "";		
					var headimg = data.headimg;
					for( var i = 0; i < data.babyList.length; i++ ){
						var baby_uid = data.babyList[i].uid;
						var account = data.babyList[i].account;
						var nickname = data.babyList[i].nickname;
						var relation = data.babyList[i].relation;
						var baby_className = data.babyList[i].baby_className;
						msg_html += "<div class='user-item' clearfix;><a href='javascript:;' class='user-item-avatar'><img src='${get_picturl_url}"+headimg+"' alt='"+account+"' width='50' height='50'></a>"	+
								"<div class='user-item-right'><p>"+account+"</p><p><i>宝宝姓名：</i>"+nickname+"</p><p><i>我是TA的：</i>"+relation+"</p>";
						if(baby_className!=null&&baby_className!=""){
							msg_html += "<p ><i>班级：</i><a href='javascript:;' target='_blank' title=''>"+baby_className+"</a></p>";
						}else{
							msg_html += "<p style='visibility: hidden'><i>班级：</i><a href='javascript:;' target='_blank' title=''></a></p>";
						}
						msg_html += "<p class='user-item-acts'><a href='javascript:;' class='button20' data-action='unbind' onclick='deleteBaby("+baby_uid+");'>取消关联</a></p></div></div>";					
					}
					$("#babyshow").html(msg_html);
				}else{
					$("#babyshow").html("");
				}
			} else {
				$("#babyshow").html("");
			}
		};
		exeAjax(ajaxUrl("${aier_url}${aier_urijs}useraccountsettings_showMyBabys${aier_suffix}"), fun, {});		
	}
	
	//取消和宝宝的关联
	function deleteBaby(baby_uid){
		if(confirm("确定取消和该宝宝的关联关系吗?")){
			var fun = function(data) {
				load_baby();
			};
			exeAjax(ajaxUrl("${aier_url}${aier_urijs}useraccountsettings_delete_baby${aier_suffix}"), fun, 
				{"baby_uid" :baby_uid});		
		}
	}
	
	
</script>






</html>